import numpy as np
from sklearn.linear_model import LinearRegression
import matplotlib.pyplot as plt
x=np.array([[100],[113],[90],[89],[60],[70],[50],[45],[55],[78]])								
y=np.array([[301],[324],[285],[296],[200],[260],[300],[120],[180],[245]])

plt.xlabel('面积')						
plt.ylabel('售价')						
plt.rcParams['font.sans-serif']='Simhei'	                          
plt.axis([40,125,100,400])		
					            

model=LinearRegression()	             
model.fit(x,y)
y2=model.predict(x)		#predict 预测值，返回值是二维数组	           

print("w=",model.coef_[0],"b=",model.intercept_)
plt.scatter(x,y,s=60,c='k',marker='o')		             
plt.plot(x,y2,'r-')		              
plt.show()

a=model.predict([[200]])
print("200平房屋的价格是：",a[0][0])

    